using Newtonsoft.Json;

namespace BootstrapBlazorApp.Server.LLMs.messages;

public class ReturnMessage
{
    [JsonProperty("role")]
    public required string Role { get; set; }
    [JsonProperty("content")]
    public required string Content { get; init; }

    [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
    public string? Name { get;set; }

    [JsonProperty("tool_calls", NullValueHandling = NullValueHandling.Ignore)]
    public List<ToolCall>? ToolCalls { get; init; }
    
    
    [JsonProperty("tool_call_id", NullValueHandling = NullValueHandling.Ignore)]
    public string? ToolCallId { get; set; }
    
    public class ToolCall
    {
        [JsonProperty("type")]
        public string Type{ get; set; } = "function";
        [JsonProperty("id")]
        public string Id { get; set; } = string.Empty;
        [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)]
        public int Index { get; set; }

        [JsonProperty("function")] 
        public Function Function { get; set; } = new();
    }
    
    public class Function
    {
        [JsonProperty("name")]
        public string Name { get; set; } = string.Empty;
        // [JsonProperty("arguments")]
        // public Dictionary<string, string> Arguments { get; set; } = new();
        [JsonProperty("arguments")]
        public string Arguments { get; set; } = string.Empty;
    }
}
